<?php
namespace Kuoqi\Api\Weixin\Mp;
use Kuoqi\Api\Weixin\Tools;
use Kuoqi\Api\Weixin\Config;

/**
 * 模板文件及发送的部分
 * Class Template
 * @package Kuoqi\Api\Weixin\Mp
 */
class Template{

    /**
     * 获取模板消息列表
     * @var string
     */
    protected  $url_list = 'https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token=%s';

    /**
     * 发送模板消息的接口
     * @var string
     */
    protected $uri_send = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=%s';
    /**
     * 获取列表的内容信息
     * @return array
     */
    public function getList(){
        $url = sprintf($this->url_list,
            Config::initAccessToken()
        );
        $response = new response(tools::sendTo($url));
        return $response->toArray();
    }

    /**
     * 发送模板消息
     * @param $config
     * @return array
     */
    public function send($config){
        $url = sprintf($this->uri_send,
            Config::initAccessToken()
        );
        $response = new response(tools::sendTo($url,'json',$config));
        return $response->toArray();
    }

}